<?php
// application/forms/Search.php

/**
 * This is the guestbook form.  It is in its own directory in the application 
 * structure because it represents a "composite asset" in your application.  By 
 * "composite", it is meant that the form encompasses several aspects of the 
 * application: it handles part of the display logic (view), it also handles 
 * validation and filtering (controller and model).  
 */
class comment_comment_Form_CommentSearch extends Zend_Form
{
    protected $_noDecorator = array(
        'ViewHelper', 
        'Errors'
    );
    
    public function cluBuild($params)
    {
//    	die_a($params);
        // set the method for the display form to POST
        $this->setMethod('POST');
		$intValidator = new Zend_Validate_Int();
//        if($params['control'] == 'ajax' || $params['control'] == 'service')
//        	$this->setAction('/en/comment/ajax/search-by-module');
//        else if($params['control'] == 'index')
//        	$this->setAction('/en/comment/index/search');
        	
        $this->setAction($params['action_url']);

        //status
        $status = new Zend_Form_Element_Select('status',  
                         array('disableLoadDefaultDecorators' => true,
                                'required' => true)); 
        $status->addMultiOption('all','--'.t(61).'--')
        	   ->addMultiOption('published',t(34))
               ->addMultiOption('queued',t(35))
               ->addMultiOption('unpublished',t(36))
               ->addMultiOption('deleted',t(37))
               ->addMultiOption('spam',t(116))
               ->addDecorators($this->_noDecorator);

        $this->addElement($status);
        
        
        //language
 		$language = new Zend_Form_Element_Select('language',  
                         array('disableLoadDefaultDecorators' => true,
                                'required' => true)); 
        $language->addMultiOption('all','--'.t(61).'--')
        		 ->addMultiOption('vi',t(40))
                 ->addMultiOption('en',t(41))
                 ->addMultiOption('cn',t(42))
                 ->addMultiOption('jp',t(43))
                 ->addDecorators($this->_noDecorator);
        $this->addElement($language);
        
        //pid
        $pid = new Zend_Form_Element_Text('pid', 
                         array('disableLoadDefaultDecorators' => true));
                               //'class' => 'inputText'));
		$pid->addValidator($intValidator)
				 ->addDecorators($this->_noDecorator);
		$this->addElement($pid);

		//  parent content id
        $content_id = new Zend_Form_Element_Text('content_id', 
                         array('disableLoadDefaultDecorators' => true));
		$content_id->addValidator($intValidator)
						->addDecorators($this->_noDecorator);
		$this->addElement($content_id);
		
		// parent content type
 		$content_type = new Zend_Form_Element_Select('content_type',  
                         array('disableLoadDefaultDecorators' => true,
                                'required' => true)); 
        $content_type->addMultiOption('all','--'.t(61).'--')
        					->addMultiOption('place',t(701))
                           	->addMultiOption('news',t(302))
                           	->addMultiOption('user',t(404))
                           	->addMultiOption('event',t(202))
                           	->addDecorators($this->_noDecorator);
        $this->addElement($content_type);
        

		// commenter id
        $poster_id = new Zend_Form_Element_Text('poster_id', 
                         array('disableLoadDefaultDecorators' => true, 
//                         			'size' => 10
                         		));
		$poster_id->addValidator($intValidator)
					->addDecorators($this->_noDecorator);
		$this->addElement($poster_id);
		
		// reply to
        $reply_to = new Zend_Form_Element_Text('reply_to', 
                         array('disableLoadDefaultDecorators' => true));
		$reply_to->addValidator($intValidator)
				->addDecorators($this->_noDecorator);
		$this->addElement($reply_to);
		        
		//rating
 		$rating = new Zend_Form_Element_Select('rating',  
                         array('disableLoadDefaultDecorators' => true));
        $rating->addMultiOption('all',t(117));
        for($i = 1; $i <=  Zend_Registry::get('configuration')->maxRating; $i++)
        	$rating->addMultiOption($i,$i);
        $rating->addDecorators($this->_noDecorator);
        $this->addElement($rating);

        //to_rating
 		$to_rating = new Zend_Form_Element_Select('to_rating',  
                         array('disableLoadDefaultDecorators' => true));
        for($i = 1; $i <=  Zend_Registry::get('configuration')->maxRating; $i++)
        	$to_rating->addMultiOption($i,$i);
        $to_rating->addDecorators($this->_noDecorator);
        $this->addElement($to_rating);
        
        //ratingOperator
 		$ratingOperator = new Zend_Form_Element_Select('ratingOperator',  
                         array('disableLoadDefaultDecorators' => true));
        $ratingOperator->addMultiOption('0',t(104))
               ->addMultiOption('before',t(118))
               ->addMultiOption('after',t(119))
               ->addMultiOption('between',t(120))
               ->addDecorators($this->_noDecorator);
        $this->addElement($ratingOperator);
        
        // orderBy
 		$orderBy = new Zend_Form_Element_Select('orderBy',  
                         array('disableLoadDefaultDecorators' => true));
        $orderBy->addMultiOption('time',t(16))
               ->addMultiOption('rating',t(117))
               ->addMultiOption('rating_count',t(121))
               ->addDecorators($this->_noDecorator);
        $this->addElement($orderBy);
        
        // asc_or_desc
        $asc_or_desc = new Zend_Form_Element_Select('asc_or_desc',  
                         array('disableLoadDefaultDecorators' => true));
        $asc_or_desc->addMultiOption('ASC',t(122))
               ->addMultiOption('DESC',t(123))
               ->addDecorators($this->_noDecorator);
        $this->addElement($asc_or_desc);
        
        //comments per page
 		$comments_per_page = new Zend_Form_Element_Select('comments_per_page',  
                         array('disableLoadDefaultDecorators' => true));
        $comments_per_page->addMultiOption(10,t(62))
               				->addMultiOption(20,t(63))
                           	->addMultiOption(30,t(64))
                           	->addMultiOption(40,t(65))
                           	->addMultiOption(50,t(66));
        $this->addElement($comments_per_page);
        
        //setOperator
        $setOperator = new Zend_Form_Element_Select('setOperator',  
                         array('disableLoadDefaultDecorators' => true));
        $setOperator->addMultiOption('time',t(16))
               				->addMultiOption('rating',t(117))
                           	->addDecorators($this->_noDecorator);
        $this->addElement($setOperator);
        
		//searchTime
        $searchTime = new Zend_Form_Element_Select('searchTime',  
                         array('disableLoadDefaultDecorators' => true));
        $searchTime->addMultiOption('simple',t(124))
   				->addMultiOption('detail',t(125))
               	->addDecorators($this->_noDecorator);
        $searchTime->setValue('detail');
        $this->addElement($searchTime);
        
		//checkTime
        $checkTime = new Zend_Form_Element_Select('checkTime',  
                         array('disableLoadDefaultDecorators' => true));
        $checkTime->addMultiOption('1',t(126))
   				   ->addMultiOption('2',t(127))
   				   ->addMultiOption('3',t(128))
               	   ->addDecorators($this->_noDecorator);
        $checkTime->setValue('1');
        $this->addElement($checkTime);
        
        // add the submit button
        $submit = new Zend_Form_Element_Submit('submit', array('disableLoadDefaultDecorators' => true, 
                                                               'label' => t(67) ));
        $submit->addDecorators($this->_noDecorator);
        $this->addElement($submit);
    }
}
?>
